\section{Utils.java} % (fold)
\label{sec:utils_java}           
In den Utils.java von DSpace ist eine kleine Anpassung notwendig, da er sonst bei dem Stream-Copy einen Buffer-Durchgang zu früh beendet. Sobald der retournierte Wert von input.read() kleiner wird als der Buffer muss man die while Schleife verlassen.

% section utils_java (end)

\begin{lstlisting}[caption={StreamBuffer Copy},firstnumber=207] 
/**
    * Copy stream-data from source to destination. This method does not buffer,
    * flush or close the streams, as to do so would require making non-portable
    * assumptions about the streams' origin and further use. If you wish to
    * perform a buffered copy, use {@link #bufferedCopy}.
    * 
    * @param input
    *            The InputStream to obtain data from.
    * @param output
    *            The OutputStream to copy data to.
    */
   public static void copy(final InputStream input, final OutputStream output)
           throws IOException
   {
       final int BUFFER_SIZE = 1024 * 4;
       final byte[] buffer = new byte[BUFFER_SIZE];

       while (true) {
           final int count = input.read(buffer, 0, BUFFER_SIZE);

           if (-1 == count)   break;	// originale Abbruchbedienung
           // write out those same bytes
           output.write(buffer, 0, count);
           if (count < BUFFER_SIZE) break; // anzahl kleiner als der Buffer -> wir sind fertig
       }                                 
       // output.flush();          // needed to flush cache 
   }     
\end{lstlisting}